﻿<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {

    }
</script>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
    <title>帐号列表</title>
    <script type="text/javascript" src="/Scripts/Commen.js"></script>
    <script type="text/javascript" src="/Scripts/AB_Account/AB_Account_Index.js"></script>
</head>
<body>
     <script type="text/javascript" src="/Scripts/ExtTimeOut.js"></script>
     <script type="text/javascript" src="/Scripts/ExtRequiredFieldPluins.js"></script>
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <!--列表数据源-->
    <ext:Store ID="AccountListStore" IDMode="Explicit" runat="server" RemoteSort="true"
        SkipIdForNewRecords="false" UseIdConfirmation="false" SerializationMode="Complex">
        <Proxy>
            <ext:HttpProxy Url="/Account/AccountListPaging/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="FId" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="FId" />
                    <ext:RecordField Name="FAccount" />
                    <ext:RecordField Name="FPassword" />
                    <ext:RecordField Name="FRoleId" />
                    <ext:RecordField Name="FEmployeeId" />
                    <ext:RecordField Name="FCreateTime" Type="Date" />
                    <ext:RecordField Name="FCreatorId" />
                    <ext:RecordField Name="FStatusId" />
                    <ext:RecordField Name="FOrgunitId" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="15" Mode="Raw" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="dir" Value="DESC" />
            <ext:Parameter Name="sort" Value="FId" />
            <ext:Parameter Name="accountParam" Value="#{AccountTFS}.getValue()" Mode="Raw" />
            <ext:Parameter Name="roleParam" Value="#{RoleCBS}.getValue()" Mode="Raw" />
            <ext:Parameter Name="statusParam" Value="#{StatusCBS}.getValue()" Mode="Raw" />
        </BaseParams>
        <SortInfo Field="FId" Direction="DESC" />
    </ext:Store>
    <!--编辑数据源-->
    <ext:Store ID="AccountEidtStore" runat="server" AutoLoad="false">
        <Proxy>
            <ext:HttpProxy Url="/Account/GetAccountMsgByFId/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="FId" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="FId" />
                    <ext:RecordField Name="FAccount" />
                    <ext:RecordField Name="FPassword" />
                    <ext:RecordField Name="FRePassword" />
                    <ext:RecordField Name="FRoleId" />
                    <ext:RecordField Name="FStatusId" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="FId" Value="#{FIdH}.getValue()" Mode="Raw" />
        </BaseParams>
        <Listeners>
            <BeforeLoad Handler="#{EditFormPanel}.el.mask('正在加载信息...', 'x-mask-loading');" />
            <LoadException Handler="#{EditFormPanel}.el.unmask();" />
            <Load Fn="AB_Account.Mgr.formStoreLoaded" />
        </Listeners>
    </ext:Store>
    <!--状态数据源-->
    <ext:Store ID="RoleStore" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/Account/GetRoleList/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="FId" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="FId" />
                    <ext:RecordField Name="FName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <!--状态数据源-->
    <ext:Store ID="StatusStore" runat="server" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/Account/GetOrderStatusList/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="FID" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="FID" />
                    <ext:RecordField Name="FName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <!--当前编辑帐号的FId-->
    <ext:Hidden ID="FIdH" IDMode="Explicit" runat="server" Text="" AutoDataBind="true">
    </ext:Hidden>
    <ext:Viewport ID="AccountViewport" runat="server" Layout="BorderLayout">
        <Items>
            <ext:FormPanel ID="EditFormPanel" runat="server" Title="帐号编辑" Region="North" Split="true"
                Height="200" Collapsible="true" Layout="HBoxLayout" Padding="5" AnchorHorizontal="100%"
                LabelWidth="100" Url="/Account/SaveAccountEdit/">
                <TopBar>
                    <ext:Toolbar ID="TopBar" runat="server">
                        <Items>
                            <ext:ToolbarFill runat="server">
                            </ext:ToolbarFill>
                            <ext:Button ID="Button2" runat="server" Text="新增" Icon="Add">
                                <Listeners>
                                    <Click Fn="AB_Account.Mgr.resetEditData" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="Button1" runat="server" Text="保存" Icon="Disk">
                                <Listeners>
                                    <Click Handler="#{EditFormPanel}.form.submit({waitMsg:'正在保存...',params:{FId:#{FIdH}.getValue()}, success:AB_Account.Mgr.successHandler , failure:AB_Account.Mgr.failureHandler});" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="Button4" runat="server" Text="删除" Icon="Delete">
                                <Listeners>
                                    <Click Fn="AB_Account.Mgr.deleteAccount" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Items>
                    <ext:Panel runat="server" Border="false" Header="false" Layout="FormLayout" LabelAlign="Left"
                        Padding="5">
                        <Items>
                            <ext:TextField ID="FAccount" runat="server" FieldLabel="帐号" AllowBlank="false" BlankText="帐号不能为空" />
                            <ext:TextField ID="FPassword" runat="server" FieldLabel="密码" InputType="Password"
                                AllowBlank="false" BlankText="密码不能为空" />
                            <ext:TextField ID="FRePassword" runat="server" FieldLabel="重复密码" InputType="Password"
                                AllowBlank="false" BlankText="重复密码不能为空" />
                        </Items>
                    </ext:Panel>
                    <ext:Panel runat="server" Border="false" Layout="FormLayout" LabelAlign="Left" Padding="5">
                        <Items>
                            <ext:ComboBox ID="FRoleId" FieldLabel="角色" runat="server" StoreID="RoleStore" TypeAhead="true"
                                Mode="Local" ForceSelection="true" TriggerAction="All" DisplayField="FName" ValueField="FId"
                                Width="137" SelectedIndex="0" />
                            <ext:ComboBox ID="FStatusId" FieldLabel="状态" runat="server" StoreID="StatusStore"
                                TypeAhead="true" Mode="Local" ForceSelection="true" TriggerAction="All" DisplayField="FName"
                                ValueField="FID" Width="137" SelectedIndex="0" />
                        </Items>
                    </ext:Panel>
                </Items>
            </ext:FormPanel>
            <ext:FormPanel ID="SearchFormPanel" runat="server" Title="筛选条件" Region="West" Width="250"
                Split="true" Collapsible="true" Layout="FormLayout" Padding="5" LabelWidth="50">
                <Items>
                    <ext:TextField ID="AccountTFS" runat="server" FieldLabel="帐号" AnchorHorizontal="100%" />
                    <ext:ComboBox ID="RoleCBS" FieldLabel="角色" runat="server" StoreID="RoleStore" TypeAhead="true"
                        Mode="Local" ForceSelection="true" TriggerAction="All" DisplayField="FName" ValueField="FId"
                        AnchorHorizontal="100%" EmptyText="请选择" />
                    <ext:ComboBox ID="StatusCBS" FieldLabel="状态" runat="server" StoreID="StatusStore"
                        TypeAhead="true" Mode="Local" ForceSelection="true" TriggerAction="All" DisplayField="FName"
                        ValueField="FID"  AnchorHorizontal="100%" EmptyText="请选择" />
                </Items>
                <Buttons>
                    <ext:Button ID="Button5" runat="server" Text="搜索" Icon="Accept">
                        <Listeners>
                            <Click Fn="AB_Account.Mgr.searchList" />
                        </Listeners>
                    </ext:Button>
                    <ext:Button ID="Button6" runat="server" Text="清空" Icon="Cancel">
                        <Listeners>
                            <Click Fn="AB_Account.Mgr.resetSearchData" />
                        </Listeners>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
            <ext:Panel ID="Panel3" runat="server" Region="Center" Layout="AccordionLayout" Split="true"
                Header="false">
                <Items>
                    <ext:GridPanel ID="AccountGrid" runat="server" Border="false" StoreID="AccountListStore"
                        TrackMouseOver="true" ClicksToEdit="0" Region="Center">
                        <ColumnModel ID="ColumnModel1" runat="server">
                            <Columns>
                                <ext:Column ColumnID="FId" DataIndex="FId" Header="编号" Hidden="true">
                                </ext:Column>
                                <ext:Column ColumnID="FAccount" DataIndex="FAccount" Header="帐号">
                                </ext:Column>
                                <ext:Column ColumnID="FRoleId" DataIndex="FRoleId" Header="角色">
                                </ext:Column>
                                <ext:Column ColumnID="FStatusId" DataIndex="FStatusId" Header="状态">
                                </ext:Column>
                                <ext:CommandColumn Width="60" Hideable="false">
                                    <Commands>
                                        <ext:GridCommand CommandName="Edit" Icon="ApplicationFormEdit" Text="修改">
                                        </ext:GridCommand>
                                    </Commands>
                                </ext:CommandColumn>
                                <ext:CommandColumn Width="60" Hideable="false">
                                    <Commands>
                                        <ext:GridCommand CommandName="Delete" Icon="Cross" Text="删除">
                                        </ext:GridCommand>
                                    </Commands>
                                </ext:CommandColumn>
                            </Columns>
                        </ColumnModel>
                        <TopBar>
                            <ext:Toolbar ID="Toolbar1" runat="server">
                                <Items>
                                    <ext:Button ID="Button3" runat="server" Text="新增" Icon="Add">
                                        <Listeners>
                                            <Click Fn="AB_Account.Mgr.resetEditData" />
                                        </Listeners>
                                    </ext:Button>
                                </Items>
                            </ext:Toolbar>
                        </TopBar>
                        <BottomBar>
                            <ext:PagingToolbar ID="PagingToolbar1" runat="server" StoreID="AccountListStore"
                                PageSize="15" />
                        </BottomBar>
                        <Listeners>
                            <Command Fn="AB_Account.Mgr.commandHandler" />
                        </Listeners>
                        <LoadMask ShowMask="true" />
                        <SelectionModel>
                            <ext:RowSelectionModel>
                            </ext:RowSelectionModel>
                        </SelectionModel>
                    </ext:GridPanel>
                </Items>
            </ext:Panel>
        </Items>
    </ext:Viewport>
    <%--
    <ext:Store ID="AccountListStore" IDMode="Explicit" runat="server" RemoteSort="true"
        SkipIdForNewRecords="false" UseIdConfirmation="false" SerializationMode="Complex">
        <Proxy>
            <ext:HttpProxy Url="/Account/AccountListPaging/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="FId" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="FId" />
                    <ext:RecordField Name="FAccount" />
                    <ext:RecordField Name="FPassword" />
                    <ext:RecordField Name="FRoleId" />
                    <ext:RecordField Name="FEmployeeId" />
                    <ext:RecordField Name="FCreateTime" Type="Date" />
                    <ext:RecordField Name="FCreatorId" />
                    <ext:RecordField Name="FStatusId" />
                    <ext:RecordField Name="FOrgunitId" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="15" Mode="Raw" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="dir" Value="DESC" />
            <ext:Parameter Name="sort" Value="FId" />
        </BaseParams>
        <SortInfo Field="FId" Direction="DESC" />
    </ext:Store>

    <ext:FieldSet runat="server" Title="搜索条件" Layout="ColumnLayout" Collapsible="true"
        Collapsed="true">
        <Items>
            <ext:TextField ID="AccountTF" runat="server" FieldLabel="帐号" LabelWidth="50" />
            <ext:Button ID="SubmitBtn" Icon="Accept" runat="server" Text="搜索" />
            <ext:Label Text="" Width="5" runat="server" />
            <ext:Button ID="CancelBtn" Icon="Cancel" runat="server" Text="清空" />
        </Items>
    </ext:FieldSet>

    <ext:GridPanel ID="AccountGrid" IIDMode="Explicit" runat="server" Border="false" StoreID="AccountListStore"
        TrackMouseOver="true" ClicksToEdit="0" Region="Center" Title="帐号列表">
        <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
                <ext:Column Width="30px" ColumnID="FId" DataIndex="FId" Header="编号" Hidden="true">
                </ext:Column>
                <ext:Column Width="60px" ColumnID="FAccount" DataIndex="FAccount" Header="帐号">
                </ext:Column>
                <ext:Column Width="70px" ColumnID="FPassword" DataIndex="FPassword" Header="密码">
                </ext:Column>
                <ext:CommandColumn Width="25" Hideable="false">
                    <Commands>
                        <ext:GridCommand CommandName="edit" Icon="ApplicationFormEdit">
                            <ToolTip Text="修改" />
                        </ext:GridCommand>
                    </Commands>
                </ext:CommandColumn>
                <ext:CommandColumn Width="25" Hideable="false">
                    <Commands>
                        <ext:GridCommand CommandName="delete" Icon="Cross">
                            <ToolTip Text="删除" />
                        </ext:GridCommand>
                    </Commands>
                </ext:CommandColumn>
            </Columns>
        </ColumnModel>
        <TopBar>
            <ext:Toolbar ID="Toolbar1" runat="server">
                <Items>
                    <ext:Button ID="Button3" runat="server" Text="新增" Icon="Add">
                        <Listeners>
                            <Click />
                        </Listeners>
                    </ext:Button>
                </Items>
            </ext:Toolbar>
        </TopBar>
        <BottomBar>
            <ext:PagingToolbar ID="PagingToolbar1" runat="server" StoreID="AccountListStore" PageSize="15" />
        </BottomBar>
        <Listeners>
            <Command />
            <RowClick />
        </Listeners>
        <LoadMask ShowMask="true" />
        <SelectionModel>
            <ext:RowSelectionModel>
            </ext:RowSelectionModel>
        </SelectionModel>
    </ext:GridPanel> --%>
    <%--
        <ext:GridPanel ID="GridPanel1" 
            runat="server"
            Title="帐号列表" 
            Frame="true"
            Height="500" >
            <TopBar>
                <ext:Toolbar ID="Toolbar1" runat="server">
                    <Items>
                        <ext:Button runat="server" Text="添加" Icon="Add">
                            <Listeners>
                                <Click Handler="#{AccountEditWindow}.show();" />
                            </Listeners>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </TopBar>
            <Store>
                <ext:Store ID="Store1" runat="server" RemoteSort="true" PageSize="5">
                    <Proxy>
                        <ext:AjaxProxy Json="true" Url="/Account/AccountPaging/">
                            <ActionMethods Read="POST" />                            
                            <Reader>
                                <ext:JsonReader Root="Data" TotalProperty="TotalRecords" />
                            </Reader>
                        </ext:AjaxProxy>
                    </Proxy>
                    <AutoLoadParams>
                        <ext:Parameter Name="start" Value="0" Mode="Raw" />
                        <ext:Parameter Name="limit" Value="5" Mode="Raw" />
                    </AutoLoadParams>
                    <Parameters>
                        <ext:StoreParameter Name="filter" Value="" Mode="Value" />
                    </Parameters>
                    <Model>
                        <ext:Model ID="Model1" runat="server">
                            <Fields>
                                <ext:ModelField Name="FId" Type="String" />
                                <ext:ModelField Name="FAccount" Type="String" />
                                <ext:ModelField Name="FPassword" Type="String" />
                            </Fields>
                        </ext:Model>
                    </Model>
                    <Sorters>
                        <ext:DataSorter Property="FId" Direction="ASC" />
                    </Sorters>
                </ext:Store>
            </Store>
            <ColumnModel ID="ColumnModel1" runat="server">
                <Columns>
                    <ext:Column runat="server" Text="编号" DataIndex="FId" Sortable="true" Flex="1" />
                    <ext:Column runat="server" Text="帐号" DataIndex="FAccount" Width="230" />
                    <ext:Column runat="server" Text="密码" DataIndex="FPassword" Width="130" />
                    <ext:CommandColumn ID="CommandColumn1" runat="server" Width="120">
                        <Commands>
                            <ext:GridCommand Icon="NoteEdit" CommandName="Edit" Text="修改" />
                            <ext:GridCommand Icon="Delete" CommandName="Delete" Text="删除" />
                        </Commands>     
                        <Listeners>
                            <Command Handler="AB_Account.Mgr.commandHandler(command, record)" />
                        </Listeners>              
                    </ext:CommandColumn>
                </Columns>
            </ColumnModel>                   
            <BottomBar>
                <ext:PagingToolbar ID="PagingToolbar1" 
                    runat="server"                     
                    DisplayInfo="true" 
                    DisplayMsg="当前显示 {0} - {1} 共 {2}" 
                    EmptyMsg="没有数据" 
                    />
            </BottomBar>
        </ext:GridPanel>

        <ext:Window 
            ID="AccountEditWindow" 
            runat="server" 
            Icon="Group" 
            Title="帐号编辑"
            Width="400" 
            Height="400"
            Hidden="true"
            Layout="Fit">
            <Loader Url="/Account/AccountEdit" AutoLoad="false" Mode="Frame" TriggerEvent="show" ReloadOnEvent="true" runat="server">
                <LoadMask ShowMask="true" Msg="正在打开页面" />
                <Params>
                </Params>
            </Loader>
            <Buttons>
                <ext:Button ID="CancelButton" runat="server" Text="关闭" Icon="Cancel">
                </ext:Button>
            </Buttons>
        </ext:Window> --%>
</body>
</html>
